using System;
using System.Collections.Generic;
using System.Text;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;

namespace MoGameLib
{
    public abstract class BattleLayer
    {
        public struct CachedLayerInfo
        {
            public Rectangle Rect;
        }

        protected CachedLayerInfo[] m_Layers;

        protected BattleTile m_Tile;

        public BattleLayer(BattleLayerType type)
        {
            m_Layers = new CachedLayerInfo[type.Layers.Length];
        }

        virtual public void Setup()
        {
            for (int i = 0; i < m_Layers.Length; i++)
            {
                if (LayerType.Layers[i].Rect == Rectangle.Empty)
                {
                    m_Layers[i].Rect = new Rectangle(0, 0,
                        LayerType.Layers[i].Image.Width, LayerType.Layers[i].Image.Height);
                }
                else
                {
                    m_Layers[i].Rect = LayerType.Layers[i].Rect;
                }
            }
        }

        public abstract BattleLayerType LayerType
        {
            get;
        }


        public virtual void Draw(SpriteBatch spriteBatch, Rectangle rect)
        {
            for (int i = 0; i < m_Layers.Length; i++)
            {
                spriteBatch.Draw(LayerType.Layers[i].Image, rect, m_Layers[i].Rect, Color.White);
            }
        }
    }
}
